<template>
	<view style="height: 100%" class="my">
		<top title="我的" color="#fff" bgc="transparent" :show="2" position="absolute"></top>
		<image src="https://cdn.xtwaixie.com/uploads/20240705/17201802276687de03b75ed.png" class="home-bg h270"></image>
		<view class="pr mt5">
			<view class="df" v-if="info.nickname">
				<button type="balanced" open-type="chooseAvatar" @chooseavatar="onChooseavatar"
					style="width: 120rpx;height: 120rpx;border: 5rpx solid #fff !important;border-radius: 50%;">
					<image referrerPolicy='no-referrer' :src="getImgSrc(info.avatar)"
						style="width: 120rpx;height: 120rpx;border-radius: 50%;">
					</image>
				</button>
				<view class="ml15">
					<view class="f24 f600 cf w200 ovh" @tap="changeName" style="width: 285rpx;">{{ info.nickname }}
					</view>
					<p class="f14 cf ml10">ID:{{ info.id }}</p>
				</view>
				<!-- <navigator class="df ac jc edit-but ml10"
					:url="'/pages/my/editInfo?name=' + info.username + '&company=' + info.company + '&mobile=' + info.company_tel + '&email=' + info.email">
					<image class="img16" src="https://wx.xtwaixie.com/img/edit1.png" mode="aspectFit|aspectFill|widthFix"
						:lazy-load="false" @error="" @load=""></image>
					<p class="f12 cf ml6">编辑企业信息</p>
				</navigator> -->
			</view>
			<view class="df ac" v-else @tap="goLogin">
				<image class="txs mr15" src="https://cdn.xtwaixie.com/uploads/20240705/17201782376687d63d0c294.png" />
				<button class="login-but">点击登录账号</button>
			</view>
			<view :class="'my-numinfo-box mt20 df ' + (info.grade == 0 ? 'jc' : '')+'  heightauto '">
				<view class="w50 df sb fc" v-if="info.grade == 0">
					<view class="">
						<h2 class="tc db f18 cf f600">入驻供应商</h2>
						<p class="mt5 tc db f12 cff8 db">获取3次报价次数</p>
					</view>
					<navigator class="settled-but" url="/pages/settled/setPage" open-type="navigate">立即入驻</navigator>
				</view>
				<view class="w50 tc df jc fc ac heightauto" v-else-if="info.grade == 1">
					<image class="img50" src="https://cdn.xtwaixie.com/uploads/20240705/17201802276687de0375783.png">
					</image>
					<!-- <p class="f18 cf f600 db tc mt3">普通供应商</p> -->
					<p class="f16 cf f600 db tc mt3">优选供应商{{info.user_type==1?'（子账号）':''}}</p>
					<p class="f10 cf db tc mt2 companyName widtheight">{{ address.company }}</p>
				</view>
				<!-- 基础会员 -->
				<view class="w50 tc df jc fc ac" v-else-if="info.grade == 2 && info.grade_type == 0" @tap="goVip"
					style="position: relative;">
					<image style="width:150rpx" mode="widthFix"
						:src="getImgSrc('/uploads/20250228/174070968667c11f3636140.png')">
					</image>
					<p class="f16 cf f600 db tc mt3">会员供应商{{info.user_type==1?'（子账号）':''}}</p>
					<p class="f10 cf op6 db tc mt2">{{ info.vip_end_at }}到期</p>
					<!-- <image src="https://cdn.xtwaixie.com/uploads/20240705/17201782366687d63cc82a9.png" v-if='showVip'
						mode="widthFix" style="position: absolute;width: 200rpx;top: -56rpx;right: -36rpx;"></image> -->
				</view>
				<!-- 至尊会员 -->
				<view class="w50 tc df jc fc ac" v-else-if="info.grade == 2 && info.grade_type == 1" @tap="goVip"
					style="position: relative;">
					<image style="width:220rpx;max-height:90rpx;"
						:src="getImgSrc('/uploads/20250228/174070970167c11f451f7ad.png')" mode="widthFix">
					</image>
					<!-- <p class="f18 cf f600 db tc mt3">至尊VIP会员</p> -->
					<p class="f16 cf f600 db tc mt3">会员供应商{{info.user_type==1?'（子账号）':''}}</p>
					<p class="f10 cf op6 db tc mt2">{{ info.vip_end_at }}到期</p>
				</view>
				<p class="numinfo-line"></p>

				<view class="w50 df sb fc rBox" v-if="info.grade == 0">
					<view class="">
						<h2 class="tc db f1f op6 cf" style="font-size: 30rpx;">报价次数剩余</h2>
						<p class="mt5 tc db f22 cf db" style="font-size: 36rpx;">{{ info.free_number }}<text
								style="font-size: 30rpx;">次</text></p>
					</view>
					<!-- 					<view class="df ac jc">
						<navigator class="recharge-but" v-if="platform != 'ios'" url="/pages/recharge/recharge"
							open-type="navigate">充值</navigator>
						<navigator class="recharge-but recharge-but1" v-if="platform != 'ios'" url="/pages/my/integral"
							open-type="navigate">明细</navigator>
						<button open-type="contact" class="customer" v-if="platform == 'ios'">联系客服</button>
					</view> -->
				</view>
				<view class="w50 df sb fc rBox" v-else-if="info.grade == 1">
					<view class="">
						<h2 class="tc db f1f op6 cf" style="font-size: 30rpx;">报价次数剩余</h2>
						<p class="mt5 tc db f22 cf db" style="font-size: 36rpx;">{{ info.free_number }}<text
								style="font-size: 30rpx;">次</text></p>
					</view>

					<view class="settled-but" v-if="!info.number_receive" @tap="onReceive"
						style="margin-top: 20rpx;border-radius:10rpx ;width: 250rpx;"> 点击免费领取3次
					</view>

					<view class="settled-but1" v-else @tap="goVip"
						style="margin-top: 20rpx;border-radius:10rpx ;width: 250rpx;height:auto;">
						<image src="https://cdn.xtwaixie.com/uploads/20240705/17201782366687d63cc82a9.png"
							mode="widthFix" style="max-height: 60rpx;"></image> 升级会员供应商
					</view>
				</view>
				<view class="w50 df sb fc rBox" v-else-if="info.grade == 2 && info.grade_type == 0">
					<view class="">
						<h2 class="tc db f1f op6 cf" style="font-size: 30rpx;">{{ address.company }}</h2>
						<p class="mt5 tc db f22 cf db" style="font-size: 36rpx;">{{ address.province }}
							{{ address.city }}
						</p>
					</view>
				</view>
				<view class="w50 df sb fc rBox"
					v-else-if="info.grade == 2 && info.grade_type == 1 && info.vip_end_date > 30">
					<view class="">
						<h2 class="tc db f1f op6 cf" style="font-size: 30rpx;">{{ address.company }}</h2>
						<p class="mt5 tc db f22 cf db" style="font-size: 36rpx;">{{ address.province }}
							{{ address.city }}
						</p>
					</view>
				</view>
				<view class="w50 df sb fc rBox"
					v-else-if="info.grade == 2 && info.grade_type == 1 && info.vip_end_date <= 30">
					<view class="">
						<h2 class="tc db f1f cf" style="font-size: 30rpx;">
							您的会员 <text class="f16 f600" style="color:red">{{info.vip_end_date}}</text>天后到期
						</h2>
						<!-- <p class="mt5 tc db f13 cf db">
							到期前续费最高立减<text class="f14 f600" style="color:red">1800</text>元
						</p> -->
						<p class="df ac jc mt8 f13">
							<view class="xufei cf" @click="goVip">立即续费</view>
						</p>
					</view>
				</view>

			</view>
			<!-- 状态提示-+ -->
			<!-- info.grade != 0 && detailUrl != '/pages/companyDetail/companyDetail?id=' + info.id && address.detail.status != 1 -->
			<view>
				<view v-if='isLogin&& info.grade != 0&&(address.detail.status==0||address.detail.status==3)'>
					<view
						v-if="info.user_type==0 && info.grade != 0 && detailUrl != '/pages/companyDetail/companyDetail?id=' + info.id && address|| !address.is_info"
						class="mt10 f13 pd10"
						style="background-color:rgba(255, 0, 0, 0.1);border-radius: 15rpx;box-sizing: border-box;max-height: 120rpx;">
						<!-- 	<image class="mr5" 
									style="width:30rpx;vertical-align: text-top;" 
									:src="img_path + '/uploads/20240924/172715716866f253b0586ef.png'" mode="widthFix">
							</image>
						<text class="mr5" style="color:#D81E07;font-weight: bold;">建议完善</text>
						您尚未完善企业资料，在工厂地图将无法获得好的排名，完善后可获得更好的展示和排名
						<navigator :url="info.nickname ? url : '/pages/login/login'" hover-class="none"
							open-type="navigate" style="color:#2456BA;display: inline-block;text-decoration: underline;margin-left: 10rpx;">
								点击完善
						</navigator> -->
						<view class="df ac sb">
							<view class="df ac">
								<view class="" style="margin-left: 0rpx;">
									<image style="width: 28rpx;height:28rpx"
										:src="getImgSrc('/uploads/20240924/172715716866f253b0586ef.png')"
										mode="aspectFill">
									</image>
								</view>
								<view class="" style="width:450rpx;margin-left: 10rpx;">
									<text v-if="address.detail.status == 0">您尚未补充企业资料，补充后可在地图上展示和排名。</text>
									<text v-if='address.detail.status == 1'>企业资料审核中</text>
									<text v-if='address.detail.status == 2'>工厂照片已通过</text>
									<text v-if="address.detail.status == 3">您的企业详细资料已驳回</text>
								</view>
							</view>
							<view class="sc-tag df ac f12" style="padding: 14rpx 15rpx;"
								v-if="address.detail.status!=2">
								<navigator :url="url" hover-class="none" open-type="navigate">
									点击补充
								</navigator>
							</view>
						</view>
					</view>
				</view>
				<view class="mt10 f13 pd10"
					style="background-color:rgba(255, 0, 0, 0.1);border-radius: 15rpx;box-sizing: border-box;max-height: 100rpx;"
					v-if="address.detail.status == 1">
					企业详细资料正在审核中...
				</view>
			</view>
			<!-- 已开通... -->
			<!-- is_show.product || is_show.renovation -->
			<view v-if="address.detail.product_status&&address.detail.img_status">
				<view class="mt10" style="background:#DFE5F6;border-radius: 15rpx;padding:15rpx 20rpx;font-size: 26rpx;"
					v-if="(address.detail.product_status!=2 || address.detail.img_status!=2 ) && isLogin&& info.grade != 0">
					<view class="df ac sb" v-if="address.detail.img_status!=2">
						<view class="df ac">
							<view class="" style="margin-left: 0rpx;">
								<image style="width: 25rpx;height:25rpx" src="https://wx.xtwaixie.com/img/warning.png"
									mode="aspectFill"></image>
							</view>
							<view style="width:450rpx;margin-left: 10rpx;">
								<text v-if='address.detail.img_status==0'>工厂照片待上传，上传后工厂排名更靠前</text>
								<text v-if='address.detail.img_status==1'>工厂照片审核中</text>
								<text v-if='address.detail.img_status==2'>工厂照片已通过</text>
								<text v-if='address.detail.img_status==3'>工厂照片被驳回</text>
							</view>
						</view>
						<view class="sc-tag df ac f12" v-if="address.detail.img_status!=2">
							<navigator url="/subPack/renovation/renovation" hover-class="none" open-type="navigate">
								上传照片
							</navigator>
						</view>
					</view>
					<view style="height: 20rpx;"
						v-if="address.detail.product_status!=2 && address.detail.img_status!=2">
					</view>
					<view class="df ac sb" v-if="address.detail.product_status!=2&& info.grade != 0">
						<!-- v-if="is_show.product" -->
						<view class="df ac">
							<view class="" style="margin-left: 0rpx;">
								<image style="width: 25rpx;height:25rpx" src="https://wx.xtwaixie.com/img/warning.png"
									mode="aspectFill"></image>
							</view>
							<view class="" style="width:450rpx;margin-left: 10rpx;">
								<text v-if='address.detail.product_status==0'>产品待上传，产品越多询价越多</text>
								<text v-if='address.detail.product_status==1'>产品审核中</text>
								<text v-if='address.detail.product_status==2'>产品已通过</text>
								<text v-if='address.detail.product_status==3'>产品被驳回</text>
							</view>
						</view>
						<view class="sc-tag df ac f12" v-if="address.detail.product_status!=2">
							<navigator url="/subPack/product/product" hover-class="none" open-type="navigate">
								点击上传
							</navigator>
						</view>
					</view>
				</view>
			</view>



			<view class="" v-if="info" :style="is_order_box ? '' : 'display: flex;flex-direction: column-reverse;'">
				<view class="bgcf br12 pd150 mt12">
					<view class="df ac sb pd015">
						<P class="f16 f600">采购管理</P>
						<!-- v-if="info && info.cg_status == 0" -->
						<view class="f14 tc cf reg_btn" v-if="info.id=='' || info.cg_status == 0" @click="goPurchaser">
							注册采购商</view>
					</view>
					<ul class="df ae mt15" style="align-items: flex-start;">
						<!-- info.nickname ? '/pages/myInquiry/myInquiry' : '/pages/login/login' -->
						<view class="tc pr" style="width: 25%;"
							@click="receivedQuotation('/pages/myInquiry/myInquiry')">
							<image class="img24" :src="img_path + '/uploads/20240924/172714432666f22186266b9.png'" />
							<br />
							<p class="db f12 c6b tc mt3">我的询价</p>
							<text class="numbox f12">({{ demandCount.count1 ? demandCount.count1 : 0 }})</text><br />
						</view>
						<view class="tc pr" style="width: 25%;"
							@click="receivedQuotations('/pages/receivedQuotation/receivedQuotation')">
							<image class="img24" :src="img_path + '/uploads/20240924/172714447466f2221acd157.png'" />
							<br />
							<p class="db f12 c6b tc mt3" style="white-space: nowrap;">收到的报价</p>
							<text class="numbox f12">({{ demandCount.count2 ? demandCount.count2 : 0 }})</text><br />
							<p class="dot-num" v-if="demandCount.count3">{{ demandCount.count3 }}</p>
						</view>
						<view class="tc pr " style="width: 25%;"
							@click="receivedQuotation('/subPack/collectedFactories/collectedFactories')">
							<image class="img24" :src="img_path + '/uploads/20240924/172714491766f223d59542a.png'" />
							<p class="db f12 c6b tc mt3" style="white-space: nowrap;">收藏的工厂</p>
							<view class="numbox f12">({{ collectCount.count3 ? collectCount.count3 : 0 }})</view> <br />
						</view>
						<view class="tc pr " style="width: 25%;"
							@click="receivedQuotation('/subPack/product/collection-product')">
							<image class="img24" :src="img_path + '/uploads/20240924/172714491766f223d59542a.png'" />
							<p class="db f12 c6b tc mt3" style="white-space: nowrap;">收藏的产品</p>
							<view class="numbox f12">({{ collectCount.count4 ? collectCount.count4 : 0 }})</view>
						</view>
					</ul>
					<ul class="df ae mt15">
						<view class="tc pr " style="width: 25%;" @click="goPurchaser"
							v-if="info.cg_status != 0&&info.is_demand==1">
							<image class="img24" :src="img_path + '/uploads/20240924/172714482566f223795de69.png'" />
							<p class="db f12 c6b tc mt3" style="white-space: nowrap;">联系信息</p>
						</view>
					</ul>
				</view>
				<view class="bgcf br12 pd150 mt12">
					<view class="df ac sb pd015">
						<P class="f16 f600">供应商管理</P>
						<view class="f12 df ac" v-if="info.grade === 2 && info.grade_type == 1">
							<view class="">
								主页展示手机号码
							</view>
							<view class="" style="transform: scale(0.8);">
								<van-switch :checked="isShowPhone" active-color="#18DD83" inactive-color="#000000"
									@change="changeShowPhone" />
							</view>
						</view>
					</view>
					<ul class="df ae mt15" style="align-items: flex-start;">
						<view class="tc pr" style="width: 25%;"
							@click="allowNotifications(info.nickname ? '/subPack/receivedInquiry/receivedInquiry' : '/pages/login/login')">
							<image class="img24" :src="img_path + '/uploads/20240923/172708442466f13788c150d.png'" />
							<br />

							<p class="db f12 c6b tc mt3" style="white-space: nowrap;">收到的询价</p>
							<p class="dot-num" v-if="orderCount.count7">{{ orderCount.count7 }}</p>
							<text class="numbox f12"
								v-if="orderCount.count6 || orderCount.count6 === 0">({{ orderCount.count6 }})</text>
						</view>
						<view class="tc pr" style="width: 25%;"
							@click="receivedQuotation(info.nickname ? '/pages/myQuotation/myQuotation' : '/pages/login/login')">
							<image class="img24" :src="img_path + '/uploads/20240923/172708701966f141ab3fbb4.png'" />
							<br />
							<p class="db f12 c6b tc mt3" style="white-space: nowrap;">报价记录</p>
							<text class="numbox f12"
								v-if="demandCount.count4 || demandCount.count4 === 0">({{ demandCount.count4 }})</text>
						</view>
						<navigator class="tc pr " style="width: 25%;" url="/subPack/contactRecords/contactRecords"
							hover-class="none" open-type="navigate">
							<image class="img24" :src="img_path + '/uploads/20240924/172714222266f2194e932ca.png'" />
							<br />
							<p class="db f12 c6b tc mt3" style="white-space: nowrap;">联系记录</p>
							<text class="numbox f12"
								v-if="collectCount.count2 || collectCount.count2 === 0">({{ collectCount.count2 }})</text><br />
						</navigator>
						<navigator class="tc pr" style="width: 25%;" url="/subPack/collection/collection">
							<image class="img24" :src="img_path + '/uploads/20240924/172714286866f21bd4148be.png'" />
							<br />
							<p class="db f12 c6b tc mt3" style="white-space: nowrap;">收藏的订单</p>
							<text class="numbox f12"
								v-if="collectCount.count1 || collectCount.count1 === 0">({{ collectCount.count1 }})</text>
						</navigator>
					</ul>
					<ul class="df ac  mt15" style="align-items: flex-start;">
						<view class="tc pr" style="width: 25%;" @click="receivedQuotation('/subPack/product/product')">
							<image class="img24" :src="img_path + '/uploads/20240924/172714312666f21cd672d50.png'" />
							<br />
							<p class="db f12 c6b tc mt3">产品管理</p>
							<text class="numbox f12"
								v-if="productCount || productCount === 0">({{ productCount }})</text>
						</view>
						<view class="tc pr" @click="receivedQuotation(url)" style="width: 25%;position: relative;">
							<image class="img24" :src="img_path + '/uploads/20240924/172714343666f21e0c8e625.png'" />
							<p class="db f12 c6b tc mt3" style="white-space: nowrap;">企业资料管理</p>
							<image :src="img_path + '/uploads/20240416/1713231546661dd6ba22970.gif'" mode="widthFix"
								style="position: absolute;width: 150rpx;height: auto;left: 50%;top: -50%;"
								v-if="address.detail.status==0&&info.grade!=0 && detailUrl != '/pages/companyDetail/companyDetail?id=' + info.id">
							</image>
						</view>
						<view class="tc pr" @click="receivedQuotation('/subPack/renovation/renovation')"
							style="width: 25%;">
							<image class="img24" :src="img_path + '/uploads/20240924/172714364666f21edeaf1f7.png'" />
							<p class="db f12 c6b tc mt3" style="white-space: nowrap;">装修主页</p>
						</view>
					</ul>
				</view>
			</view>
			<!-- <view class="bgcf br12 pd150 mt12">
				<view class="df ac sb pd015">
					<P class="f16 f600">商城订单</P>
					<navigator class="df ac" :url="info.nickname ? '/pages/myOrder/orderList' : '/pages/login/login'"
						hover-class="none" open-type="navigate">
						<p class="f12 c9d">全部订单</p>
						<image class="more ml8" src="https://wx.xtwaixie.com/img/more.png" />
					</navigator>
				</view>
				<ul class="df ac sa mt15">
					<navigator class="tc pr"
						:url="info.nickname ? '/pages/myOrder/orderList?act=1' : '/pages/login/login'"
						hover-class="none" open-type="navigate">
						<image class="img24" src="https://wx.xtwaixie.com/img/o1.png" />
						<p class="db f12 c6b tc mt3">待付款</p>
						<p class="dot-num" v-if="orderCount.count1">{{ orderCount.count1 }}</p>
					</navigator>
					<navigator class="tc pr"
						:url="info.nickname ? '/pages/myOrder/orderList?act=2' : '/pages/login/login'"
						hover-class="none" open-type="navigate">
						<image class="img24" src="https://wx.xtwaixie.com/img/o2.png" />
						<p class="db f12 c6b tc mt3">待发货</p>
						<p class="dot-num" v-if="orderCount.count2">{{ orderCount.count2 }}</p>
					</navigator>
					<navigator class="tc pr"
						:url="info.nickname ? '/pages/myOrder/orderList?act=3' : '/pages/login/login'"
						hover-class="none" open-type="navigate">
						<image class="img24" src="https://wx.xtwaixie.com/img/o3.png" />
						<p class="db f12 c6b tc mt3">待收货</p>
						<p class="dot-num" v-if="orderCount.count3">{{ orderCount.count3 }}</p>
					</navigator>
					<navigator class="tc pr"
						:url="info.nickname ? '/pages/myOrder/orderList?act=5' : '/pages/login/login'"
						hover-class="none" open-type="navigate">
						<image class="img24" src="https://wx.xtwaixie.com/img/o4.png" />
						<p class="db f12 c6b tc mt3">已完成</p>
						<p class="dot-num" v-if="orderCount.count4">{{ orderCount.count4 }}</p>
					</navigator>
					<navigator class="tc pr" :url="info.nickname ? '/pages/myOrder/returnList' : '/pages/login/login'"
						hover-class="none" open-type="navigate">
						<image class="img24" src="https://wx.xtwaixie.com/img/o5.png" />
						<p class="db f12 c6b tc mt3">退货/售后</p>
						<p class="dot-num" v-if="orderCount.count5">{{ orderCount.count5 }}</p>
					</navigator>
				</ul>
			</view> -->
			<view class="bgcf br12 pd150 mt12">
				<view class="df ac sb pd015">
					<P class="f16 f600">联系我们</P>
				</view>
				<ul class="df ac mt15" style="flex-wrap: wrap;">
					<button class="tc pr kf-but1" open-type="contact">
						<image class="img24" src="https://wx.xtwaixie.com/img/kf2.png" />
						<p class="db f12 c6b tc mt3 f400">平台客服</p>
					</button>
					<!-- <navigator class="tc pr w20"
						:url="info.nickname ? '/pages/address/addressList?type=1' : '/pages/login/login'"
						hover-class="none" open-type="navigate">
						<image class="img24" src="https://wx.xtwaixie.com/img/o7.png" />
						<p class="db f12 c6b tc mt3">收货及发票</p>
					</navigator> -->
					<button class="tc pr ma0 pd0 w20" open-type="contact">
						<image class="img24" src="https://wx.xtwaixie.com/img/o9.png" />
						<p class="db f12 c6b tc mt3 f400">广告合作</p>
					</button>
					<navigator class="tc pr" url="/pages/share/qrshare" hover-class="none" open-type="navigate">
						<image class="img24" src="https://wx.xtwaixie.com/img/pack.png" />
						<p class="db f12 c6b tc mt3">采购工具包</p>
					</navigator>
					<navigator class="tc pr w20" url="/pages/help/help" hover-class="none" open-type="navigate">
						<image class="img24" src="https://wx.xtwaixie.com/img/o12.png" />
						<p class="db f12 c6b tc mt3">帮助中心</p>
					</navigator>
					<navigator class="tc pr w20" url="/pages/qualifications/qualifications" hover-class="none"
						open-type="navigate">
						<image class="img24" src="https://wx.xtwaixie.com/img/o10.png" />
						<p class="db f12 c6b tc mt3" style="white-space: nowrap;">平台资质公示</p>
					</navigator>
				</ul>
			</view>
		</view>
		<van-popup :show="showRequest" custom-style='background:#00000000;'>
			<image src="https://cdn.xtwaixie.com/uploads/20240108/1704702779659bb33b1136b.png" mode="widthFix"
				style="width: 450rpx;padding-bottom: 800rpx;"></image>
		</van-popup>
		<model :value='showTips' title='提示' content="恭喜您已获得3次查看联系方式机会" :showdisagreeBtn='false' agreeBtn='确认'
			@change='changeTips()' @agree='confirmSale' color='#1A4FBF' />

		<!-- <van-popup :show="!complete_information && info.grade>0" round >
			<p class="df ac jc pd200 mt5 w311">
				<span class="f16 c28 f500">请完善公司资料信息</span>
			</p>
			
			<view class="df ac btf1 h48 mt15">
				<p class="w50 tc f16 c28" @tap.native="complete_information = true">取消</p>
				<button class="share-but1 h48 c10" @tap="goSettledInfo">去完善</button>
			</view>
		</van-popup> -->

		<van-popup :show="is_receive" round @close="is_receive = false">
			<p class="df ac jc pd200 mt5 w311">
				<span class="f16 c28 f500">子账户无法领取</span>
			</p>
			<p class='df ac jc btf1 f16 c10 h48' @tap="is_receive = false">我知道了</p>
		</van-popup>

		<van-popup :show="is_operate" round @close="is_operate = false">
			<p class="df ac jc pd200 mt5 w311">
				<span class="f16 c28 f500">子账户无权限操作</span>
			</p>
			<p class='df ac jc btf1 f16 c10 h48' @tap="is_operate = false">我知道了</p>
		</van-popup>

		<!-- 装修主页弹窗 -->
		<van-popup :show="is_upImg" z-index='10000' :close-on-click-overlay='true'
			custom-style='background:rgba(0,0,0,0);' @close="closePop(0)">
			<view class="popupBox">
				<image referrerPolicy='no-referrer' :src="getImgSrc('/uploads/20241223/17349277246768e56c0cf9a.png')"
					mode="widthFix" class="popupImg" @click="receivedQuotation('/subPack/renovation/renovation')"
					style="width: 610rpx;"></image>
			</view>
		</van-popup>

		<!-- 补充资料弹窗 -->
		<van-popup :show="is_upInfo" z-index='10000' :close-on-click-overlay='true'
			custom-style='background:rgba(0,0,0,0);' @close="closePop(1)">
			<view class="popupBox">
				<image referrerPolicy='no-referrer' :src="getImgSrc('/uploads/20241223/17349323006768f74c51071.png')"
					mode="widthFix" class="popupImg"
					@click="receivedQuotation('/pages/Factoryinformation/Factoryinformation')" style="width: 610rpx;">
				</image>
			</view>
		</van-popup>

		<tabbar :unReadNum="unReadNum"></tabbar>
	</view>
</template>
<script>
	import {
		mapState,
		mapActions
	} from 'vuex'

	import {
		verifyPhoneNumber
	} from "@/utils/util"
	import day from "../../utils/day.js"
	import model from '@/component/model';
	import tabbar from '@/component/tabbar/tabbar';
	import top from '@/component/top/top';
	const http = require('../../utils/http');
	export default {
		components: {
			tabbar,
			top,
			model
		},
		data() {
			return {
				is_upImg: false,
				is_upInfo: false,
				is_receive: false,
				is_operate: false,
				img_path: http.img_path,
				detailUrl: '/pages/editSettled/editSettled',
				show: false,
				info: {
					nickname: '',
					avatar: '',
					id: '',
					username: '',
					company: '',
					mobile: '',
					email: '',
					grade: 0,
					vip_end_at: '',
					current_integral: ''
				},
				renovation_status: 0, //工厂照片审核状态
				url: '/pages/editSettled/editSettled',
				showTips: false,
				get_number: true,
				avatarUrl: '',
				base_info: {},
				orderCount: {
					count1: '',
					count2: '',
					count3: '',
					count4: '',
					count5: ''
				},
				productCount: 0,
				collectCount: {},
				platform: '',
				address: '',
				demandCount: {},
				infoDetail: {},
				showVip: false,
				showRequest: false,
				infoShow: false,
				is_order_box: false,
				isShowPhone: false,
				is_show: {
					product: false,
					renovation: false
				},
				isLogin: false,
				complete_information: true,
				callback: null
			};
		},
		onLoad(options) {
			this.getBase();
			let obj = uni.getSystemInfoSync();
			this.setData({
				platform: obj.platform
			});


			// this.getUserInfo()
			// console.log(this.info)
			// console.log(this.isShowPhone,111)

		},
		watch: {
			is_upImg(val) {
				if (val) {
					uni.setStorageSync('upImg_time', day().format("YYYY-MM-DD"));
				}
			}
		},
		computed: {
			...mapState('my', ['unReadNum'])
		},
		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady() {},
		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow() {
			const token = uni.getStorageSync('token');
			const login_code = uni.getStorageSync('is_login')
			if (token && login_code == 200) {
				this.isLogin = true
				this.getUserInfo();
			} else {
				this.is_order_box = true
			}
		},
		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide() {},
		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload() {
			clearTimeout(this.callback)
		},
		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh() {},
		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom() {},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage() {},
		methods: {
			...mapActions('my', ['updateUnReadNum']),
			changeName() {
				uni.navigateTo({
					url: "/pages/changeName/changeName?name=" + this.info.nickname
				})
			},
			changeShowPhone({
				detail
			}) {
				// this.isShowPhone = detail
				if (this.info.user_type === 1) {
					this.is_operate = true
					return
				}
				http.request('user/editUserSettled', {
					is_show_mobile: this.isShowPhone ? 0 : 1
				}).then(res => {
					console.log(res)
					// this.isShowPhone
					http.request('user/settledInfo').then(rest => {
						this.isShowPhone = rest.data.info.is_show_mobile == 1
						// console.log(this.isShowPhone)
						uni.showToast({
							title: res.message,
							icon: 'none'
						})

					})
				}).catch(err => {
					console.log(err)
					uni.showToast({
						title: err.message,
						icon: 'none'
					})
				})
			},
			// 判断当前时间和上次展示装修主页的时间是不是相差一天
			verificationTime() {
				let pre_time = uni.getStorageSync('upImg_time');
				console.log(pre_time)
				if (!pre_time) {
					return true
				}
				console.log('上次提示时间:', pre_time, day(pre_time).diff(day(), 'day'))
				console.log(day(pre_time).diff(day(), 'day') < 0)
				return day(pre_time).diff(day(), 'day') < 0
			},
			// receivedQuotations(index) {
			// 	uni.requestSubscribeMessage({
			// 		tmplIds: ['5SQbIg20NgfTt5-y7GY8BRzxqvrinsp-GnKzQIPcNPo',
			// 			'VFzK9QykUmGyTn9YRVHrxmihxNELMsUhJxvTWnhNHa8'
			// 		],
			// 		complete(res) {
			// 			uni.navigateTo({
			// 				url: index
			// 			})
			// 		}
			// 	})
			// },
			receivedQuotations(index) {
				uni.requestSubscribeMessage({
					tmplIds: ['5SQbIg20NgfTt5-y7GY8BRzxqvrinsp-GnKzQIPcNPo'],
					complete(res) {
						uni.navigateTo({
							url: index
						})
					}
				})
			},
			receivedQuotation(index) {
				const url = index === '/subPack/renovation/renovation' || index === '/subPack/product/product' || index ===
					'/pages/Factoryinformation/Factoryinformation'

				console.log(this.info.user_type === 1 && url, url)
				if (this.info.user_type === 1 && url) {
					this.is_operate = true
					return
				}
				uni.navigateTo({
					url: index
				})
			},
			onChooseavatar(e) {
				let self = this;
				let {
					avatarUrl
				} = e.detail;
				uni.showLoading({
					title: '加载中'
				});
				http.upLoadFile('base/uploadImg', 'image', avatarUrl, {}).then((ress) => {
					if (ress.code == 200) {
						http.request('user/updateAvatar', {
							avatar: ress.data.url
						}).then((res) => {
							self.info.avatar = ress.data.url
							uni.hideLoading();
							uni.showToast({
								title: "修改成功"
							});
						}).catch((res) => {
							uni.showToast({
								title: res.message,
								icon: 'none'
							});
						});
					}
				}).catch((res) => {
					uni.hideLoading();
					uni.showToast({
						title: res.message,
						icon: 'none'
					});
				});
			},
			goSettledInfo() {
				uni.navigateTo({
					url: '/pages/Factoryinformation/Factoryinformation'
				});
			},
			closePop(type) {
				if (type === 1) {
					this.is_upInfo = false
					if (this.is_show.product) {
						setTimeout(() => {
							if (this.verificationTime()) {
								this.is_upImg = true
							}
						}, 50)
					}
				} else {
					this.is_upImg = false
				}
			},
			// 获取个人信息
			getUserInfo() {
				http.request('user/userInfo').then((rest) => {
					if (rest.data.userInfo.grade == 0) {
						this.is_order_box = true
					}
					uni.setStorageSync('is_info', rest.data.is_info);
					const orderCount = rest.data.orderCount
					const demandCount = rest.data.demandCount
					let count = orderCount.count7 + demandCount.count3
					this.updateUnReadNum(count);
					this.setData({
						info: rest.data.userInfo,
						orderCount: rest.data.orderCount,
						demandCount: rest.data.demandCount,
						collectCount: rest.data.collectCount,
						productCount: rest.data.productCount,
						complete_information: rest.data.is_info,

					});
					this.info.nickname = this.info.nickname ? this.info.nickname : '微信用户'
					if (this.info.grade == 2) {
						let vip_end_at = `${this.info.vip_end_at} 23:59:59`
						if ((new Date(vip_end_at) - new Date()) / (1 * 24 * 60 * 60 * 1000) <= 30) {
							this.showVip = true
						} else {
							this.showVip = false
						}
					}
					const url_1 = '/pages/Factoryinformation/Factoryinformation'
					const url_2 = '/pages/editSettled/editSettled'
					this.url = rest.data.userInfo.settledStatus ? url_1 : url_2
					if (this.info.grade !== 0) {
						http.request('user/settledInfo').then((res) => {
							this.address = res.data.info
							console.log(this.address, "this.address")
							this.settledStatus = res.data.info.settledStatus
							this.isShowPhone = res.data.info.is_show_mobile == 1
							// console.log(this.info)
							// 初始判断是否是超级会员，主页展示手机号码
							// if(this.info.grade === 2 && this.info.grade_type == 1){
							// 	this.isShowPhone = true
							// }
							const products = res.data.info.detail.products || []
							const myLogo = this.address.detail.logo
							const myBoorboard = this.address.detail.doorboard
							if (products.length < 1) {
								this.is_show.product = true
							}
							// myLogo == '' || myBoorboard == '' || !myLogo || 
							if (!myLogo || !myBoorboard) {
								this.is_show.renovation = true
							}
							if (!this.info.settledStatus) {
								// console.log(this.info.settledStatus);
								this.detailUrl = '/pages/editSettled/editSettled'
							} else {
								if (this.address.detail && this.address.detail.status == 2) {
									this.detailUrl = '/pages/companyDetail/companyDetail?id=' + this.info
										.id
									// if(products.length < 1)
									if (this.verificationTime()) {
										if (!myBoorboard) {
											this.is_upImg = true
										} else {
											if (myBoorboard.length < 1) {
												this.is_upImg = true
											}
										}
									}
								} else {
									// if(this.address.detail.status !=1){
									// 	this.is_upInfo = true
									// }
									if (this.verificationTime()) {
										if (this.address.detail.status != 1 && this.address.detail
											.status != 3) {
											this.is_upInfo = true
										}

									}
									this.detailUrl = '/pages/Factoryinformation/Factoryinformation'
								}
							}
							// 工厂资料弹窗
							if (!this.address.is_info) {
								if (this.verificationTime()) {
									if (this.address.detail.status != 1 && this.address.detail.status !=
										3) {
										this.is_upInfo = true
									}
								}
							}
							// let count = this.orderCount.count7 + this.demandCount.count3
							// const lastVisit = uni.getStorageSync('lastVisitDate');
							// const today = new Date().toDateString();
							// const flag = this.address.detail.logo == '' || this.address.detail.doorboard == '' || products.length < 1 || this.detailUrl != '/pages/companyDetail/companyDetail?id=' + this.info
							// 			.id
							// if(flag && this.info.userInfo.cg_status != 2){
							// 	if(lastVisit != today){
							// 		count += 1
							// 	}
							// 	this.updateUnReadNum(count);
							// }
						}).catch((res) => {
							uni.showToast({
								title: res.msg,
								icon: 'none'
							});
						});
					}
					// console.log(this.info)
					// if(this.info.grade == 2){
					// 	if(this.info.grade_type == 1){
					// 		this.isShowPhone = true
					// 		console.log(this.isShowPhone,222)
					// 	}
					// }
				}).catch((err) => {
					uni.showToast({
						title: err.message,
						icon: 'none'
					});
				});
			},
			goPurchaser() {
				this.callback = verifyPhoneNumber()
				if (this.callback) return
				// if (this.info.id == "") {
				// 	this.goLogin()
				// 	return
				// }
				if (this.info.cg_status == 0 || this.info.cg_status == 3 || this.info.cg_status == 1 || !uni
					.getStorageSync('token')) {
					uni.navigateTo({
						url: '/pages/my/editInfo'
					})
				} else {
					uni.navigateTo({
						url: '/subPack/purchaserInfo/purchaserInfo'
					})
				}
			},
			onReceive() {
				if (this.info.user_type === 1) {
					this.is_receive = true
					return
				}
				if (!this.info.settledInfoStatus) {
					// this.infoShow = true
					this.receive()
					// this.$forceUpdate()
				} else {
					this.receive()
				}

				return
				uni.getProvider({
					service: "oauth",
					success: function(res) {
						console.log(res)
						if (~res.provider.indexOf("weixin")) {
							uni.getUserProfile({
								desc: "获取你的昵称",
								success: (res) => {
									//这里请求接口
									_this.receive({
										nickname: res.userInfo.nickName
									});
								},
								fail: (res) => {
									// _this.receive()
								},
							});
						} else {
							// _this.receive()
						}
					},
				});
			},
			changeTips() {
				this.showTips = false
			},
			confirmSale() {
				this.showTips = false
			},
			receive(data = {}) {
				let first = uni.getStorageSync("firstPopup")
				if (!first) {
					this.showRequest = true
					uni.setStorageSync('firstPopup', true)
				}
				let popupTime = uni.getStorageSync('popupTime');
				if (popupTime) {
					let nowDate = new Date().setHours(0, 0, 0, 0)
					if (nowDate > popupTime) {
						let that = this
						uni.requestSubscribeMessage({
							tmplIds: ['Ps_TGNHTlkFPLHybskEltaWoAvSZ1GhsoXfiJBGwTjA'],
							success(res) {
								if (res.Ps_TGNHTlkFPLHybskEltaWoAvSZ1GhsoXfiJBGwTjA == 'accept') {
									http.request('demand/empower')
									uni.setStorageSync('popupTime', new Date().getTime())
								}
								that.showRequest = false
								http.request('user/receive', data).then((res) => {
									that.getUserInfo()
									that.showTips = true
									setTimeout(() => {
										that.showTips = false
									}, 2000);
								}).catch((res) => {
									uni.showToast({
										title: res.message,
										icon: 'none'
									});
								});
							}
						})
					} else {
						let that = this
						that.showRequest = false
						http.request('user/receive', data).then((res) => {
							that.getUserInfo()
							that.showTips = true
							setTimeout(() => {
								that.showTips = false
							}, 2000);
						}).catch((res) => {
							uni.showToast({
								title: res.message,
								icon: 'none'
							});
						});
					}
				} else {
					let that = this
					uni.requestSubscribeMessage({
						tmplIds: ['Ps_TGNHTlkFPLHybskEltaWoAvSZ1GhsoXfiJBGwTjA'],
						success(res) {
							if (res.Ps_TGNHTlkFPLHybskEltaWoAvSZ1GhsoXfiJBGwTjA == 'accept') {
								http.request('demand/empower')
								uni.setStorageSync('popupTime', new Date().getTime())
							}
							that.showRequest = false
							http.request('user/receive', data).then((res) => {
								that.getUserInfo()
								that.showTips = true
								setTimeout(() => {
									that.showTips = false
								}, 2000);
							}).catch((res) => {
								uni.showToast({
									title: res.message,
									icon: 'none'
								});
							});
						}
					})
				}
			},
			goVip() {
				uni.navigateTo({
					url: '/pages/recharge/recharge?user_type=' + this.info.user_type
				});
				// if (this.platform === 'ios') {
				// 	uni.navigateTo({
				// 		url: '/pages/recharge/iosvip'
				// 	});
				// } else {
				// 	uni.navigateTo({
				// 		url: '/pages/recharge/recharge'
				// 	});
				// }
			},
			getBase() {
				http.request('base/configData').then((res) => {
					this.setData({
						base_info: res.data
					});
				}).catch((res) => {
					console.log(res);
				});
			},
			showPopup() {
				this.setData({
					show: true
				});
			},
			// onClose() {
			// 	this.setData({
			// 		show: false
			// 	});
			// },
			// 撥打電話
			onCall(e) {
				let tel = e.currentTarget.dataset.tel;
				uni.makePhoneCall({
					phoneNumber: tel,
					complete() {
						this.onClose();
					}
				});
			},
			// 保存图片
			saveImage() {
				let that = this;
				uni.showLoading({
					title: '保存中...',
					mask: true
				});
				uni.downloadFile({
					url: that.base_info.service_qrcode,
					success(res) {
						if (res.statusCode === 200) {
							let img = res.tempFilePath;
							uni.saveImageToPhotosAlbum({
								filePath: img,
								success(res) {
									uni.showToast({
										title: '保存成功',
										icon: 'success',
										duration: 2000
									});
									that.onClose();
								},
								fail(res) {
									that.onClose();
									uni.showToast({
										title: '保存失败',
										icon: 'none',
										duration: 2000
									});
								}
							});
						}
					}
				});
			},
			goLogin() {
				uni.navigateTo({
					url: '/pages/login/login'
				});
			},
			// 查看收到的询价订阅通知
			allowNotifications(event, params) {
				this.callback = verifyPhoneNumber()
				if (this.callback) return
				// const token = uni.getStorageSync('token')
				// // console.log(token)
				// if (!token) {
				// 	uni.navigateTo({
				// 		url: '/pages/login/login'
				// 	});
				// 	return false;
				// }
				// 检查用户是否已经订阅过
				const hasSubscribed = uni.getStorageSync('hasSubscribed');
				const that = this
				if (!hasSubscribed) {
					// 用户未订阅，请求订阅
					uni.requestSubscribeMessage({
						tmplIds: ['X5UgYbTKPQn_PmMMUKoZOV7iH_ON5vpemjP4QThHFjo'], // 替换为你的模板 ID
						success(res) {
							// 判断用户是否同意订阅
							if (res['X5UgYbTKPQn_PmMMUKoZOV7iH_ON5vpemjP4QThHFjo'] === 'accept') {
								// 用户同意订阅，存储订阅成功的状态
								uni.setStorageSync('hasSubscribed', true); // 标记为已订阅
								console.log('用户成功订阅');

							}
							that.receivedQuotation(event, params);
						},

						fail(err) {
							console.log('订阅消息请求失败', err); // 捕获订阅请求失败的错误
							that.receivedQuotation(event, params);
						}

					});
				} else {
					this.receivedQuotation(event, params)
					console.log('用户已订阅，跳过请求');
				}


			},
		}
	};
</script>
<style lang="scss">
	@import './my.css';

	.settled-but {
		font-family: PingFangSC, PingFangSC-Regular;
		font-weight: bold;
	}

	.rBox {
		display: flex;
		height: 176rpx;
		align-items: center;
		flex-direction: column;
		justify-content: center;
	}

	.companyName {
		font-size: 24rpx;
		opacity: .8;
		// overflow: hidden;
		/*   超出容器的部分影响  */
		// white-space: nowrap;
		/*  文本不换行   */
		// text-overflow: ellipsis;
		/*  超出容器的文本显示省略号  */
		height: auto;
		text-align: center;
	}

	.numbox {
		color: #65C27D;
	}

	.heightauto {
		height: auto;
	}

	.widtheight {
		width: 80%;
		margin: auto;
		height: auto;
		word-break: break-all;
	}

	.share-but1 {
		width: 50% !important;
		font-size: 32rpx;
		padding: 0 !important;
		margin: 0 !important;
		font-weight: 400;
		text-align: center;
		color: #283043;
		line-height: 94rpx !important;
		border-left: 1rpx solid #ebedf0;
	}

	.reg_btn {
		width: 200rpx;
		height: 56rpx;
		background: $xt-primary;
		border-radius: 30rpx;
		line-height: 56rpx;
	}
</style>